import 'package:cloudapp/pages/base.dart';
import 'package:cloudapp/pages/cloud_album_page.dart';
import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';

// 同步程序主界面
class ESyncMainPage extends StatefulWidget {
  static const pageName = "/main";

  @override
  State<StatefulWidget> createState() {
    return _ESyncMainPage();
  }
}

class _ESyncMainPage extends BaseState<ESyncMainPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("同步"),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Container(
            height: 100.0,
          ),
          Container(
            child: Text('同步项目'),
          ),
          buildDcimItem(),
          RaisedButton(
            child: Text('获取手机信息'),
            onPressed: getPhoneInfo,
          )
        ],
      ),
    );
  }

  Widget buildDcimItem() {
    return InkWell(
      onTap: goPicture,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Image.asset(
            'res/images/picture.png',
            width: 48,
            height: 48,
          ),
          Text('相册'),
        ],
      ),
    );
  }

  void goPicture() {
    Navigator.pushNamed(context, CloudAlbumPage.pageName);
  }

  /*
    this.version,
    this.board,
    this.bootloader,
    this.brand,
    this.device,
    this.display,
    this.fingerprint,
    this.hardware,
    this.host,
    this.id,
    this.manufacturer,
    this.model,
    this.product,
    List<String> supported32BitAbis,
    List<String> supported64BitAbis,
    List<String> supportedAbis,
    this.tags,
    this.type,
    this.isPhysicalDevice,
    this.androidId,
   */
  void getPhoneInfo() async {
    var deviceInfo = DeviceInfoPlugin();
    AndroidDeviceInfo info = await deviceInfo.androidInfo;
    print('Running on ${info.model}');
    print('info $info');
    print('manufacturer: ${info.manufacturer}');
    print('version: ${info.version}');
    print('board: ${info.board}');
    print('bootloader: ${info.bootloader}');
    print('device: ${info.device}');
    print('display: ${info.display}');
    print('fingerprint: ${info.fingerprint}');
    print('hardware: ${info.hardware}');
    print('host: ${info.host}');
    print('id: ${info.id}');
    print('product: ${info.product}');
    print('tags: ${info.tags}');
    print('type: ${info.type}');
    print('isPhysical: ${info.isPhysicalDevice}');
    print('android id: ${info.androidId}');
  }
}
